package com.icss.ah.fullReduce.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class FullStatisticsService {
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	private final Logger errlog = Logger.getLogger("E");
	private final Logger infolog = Logger.getLogger("I");
	
	/**
	 * 查询满减活动统计列表
	 * @param map
	 * @return
	 */
	public List<Map> queryReduceList(HashMap map) {
		List<Map> list = new ArrayList<Map>();
		try{
			list = sqlSessionTemplate.selectList("FullStatisticsBean.queryReduceList", map);
			infolog.info("FullStatisticsService|queryReduceList|list:"+list);
		} catch (Exception ex) {
			ex.printStackTrace();
			errlog.error("FullStatisticsService|queryReduceList", ex);
		} 
		return list == null ? new ArrayList<Map>() : list;
	}
	
	/**
	 * 查询满减活动统计总记录数
	 * @param map
	 * @return
	 */
	public long queryReduceCount(HashMap map) {
		Long reValue = 0l;
		try {
			reValue = (Long)sqlSessionTemplate.selectOne("FullStatisticsBean.queryReduceCount", map);
			infolog.info("FullStatisticsService|queryReduceCount|reValue:"+reValue);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("FullStatisticsService|queryReduceCount", e);
		} 
		return reValue;
	}
	
	/**
	 * 查询满减/返活动统计列表
	 * @param map
	 * @return
	 */
	public List<Map> queryOrderList(HashMap map) {
		List<Map> list = new ArrayList<Map>();
		try{
			list = sqlSessionTemplate.selectList("FullStatisticsBean.queryOrderList", map);
			infolog.info("FullStatisticsService|queryOrderList|list:"+list);
		} catch (Exception ex) {
			ex.printStackTrace();
			errlog.error("FullStatisticsService|queryOrderList", ex);
		} 
		return list == null ? new ArrayList<Map>() : list;
	}
	
	/**
	 * 查询满减/返活动统计总记录数
	 * @param map
	 * @return
	 */
	public long queryOrderCount(HashMap map) {
		Long reValue = 0l;
		try {
			reValue = (Long)sqlSessionTemplate.selectOne("FullStatisticsBean.queryOrderCount", map);
			infolog.info("FullStatisticsService|queryOrderCount|reValue:"+reValue);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("FullStatisticsService|queryOrderCount", e);
		} 
		return reValue;
	}
	
	/**
	 * 查询满返活动统计列表
	 * @param map
	 * @return
	 */
	public List<Map> queryReturnList(HashMap map) {
		List<Map> list = new ArrayList<Map>();
		try{
			list = sqlSessionTemplate.selectList("FullStatisticsBean.queryReturnList", map);
			infolog.info("FullStatisticsService|queryReturnList|list:"+list);
		} catch (Exception ex) {
			ex.printStackTrace();
			errlog.error("FullStatisticsService|queryReturnList", ex);
		} 
		return list == null ? new ArrayList<Map>() : list;
	}

	/**
	 * 查询满返活动统计总记录数
	 * @param map
	 * @return
	 */
	public long queryReturnCount(HashMap map) {
		Long reValue = 0l;
		try {
			reValue = (Long)sqlSessionTemplate.selectOne("FullStatisticsBean.queryReturnCount", map);
			infolog.info("FullStatisticsService|queryReturnCount|reValue:"+reValue);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("FullStatisticsService|queryReturnCount", e);
		} 
		return reValue;
	}
	
	/**
	 * 查询店铺信息
	 * @param map
	 * @return
	 */
	public HashMap queryShopMap(HashMap<String, Object> map) {
		HashMap reMap = new HashMap();
		try {
			reMap = (HashMap)sqlSessionTemplate.selectOne("FullStatisticsBean.queryShopMap",map);
			infolog.info("FullStatisticsService|queryShopMap|reMap:"+reMap);
		} catch (Exception ex) {
			ex.printStackTrace();
			errlog.error("FullStatisticsService|queryShopMap", ex);
		} 
		return reMap = reMap == null ? new HashMap() : reMap;
	}
	/**
	 * 查询消费者留言信息
	 * @param map
	 * @return
	 */
	public HashMap queryMessageMap(HashMap<String, Object> map) {
		HashMap reMap = new HashMap();
		try {
			reMap = (HashMap)sqlSessionTemplate.selectOne("FullStatisticsBean.queryMessageMap",map);
			infolog.info("FullStatisticsService|queryMessageMap|reMap:"+reMap);
		} catch (Exception ex) {
			ex.printStackTrace();
			errlog.error("FullStatisticsService|queryMessageMap", ex);
		} 
		return reMap = reMap == null ? new HashMap() : reMap;
	}

}
